<% 
    var headContent = {
%>
<style>
 /*列表选择项宽度 begin*/
.table-check {
width: 80px;
text-align: center;
}
/*列表选择项宽度 end*/

 </style>
<%
};
%>
    
<%layout("/common/_layout.html",{head:headContent}){ %>
  <%#ajax userTable:{%>
  <div class="am-cf am-padding">
    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">系统管理</strong> / <small>前端展示模块配置</small></div>
  </div>
  <form class="am-form" id="listForm" action="${base}/website/list" method="post">
   <div class="am-g">
     <div class="am-u-sm-2 am-u-md-2">
       <p>
       		网点类型: ${class_name}
       </p>
     </div>
     </div>
    <div class="am-g">
     <div class="am-u-sm-4  am-u-md-4">
                    <select id="org_id" name="org_id" data-am-selected="{btnSize: 'sm', maxHeight: 200}" style="height:24rem;overflow-y:auto">
                    <%for(list in org.list!){%>
		                <option value=${list.id!} 
	                    <%if (list.id==org_id){%>
	                       selected = "selected"
	                    <%}%>
	                      >${list.DisplayName!} 
	                    </option>
		            <%}%> 
                    </select>
                    
    </div>
      </div>
   <div class="am-g" style="padding-top:1rem">
     <div class="am-u-sm-12">
         <table class="am-table  am-table-hover table-main">
             <thead>
                 <tr>
                     <th class="table-check"><input  class="table-title" style="text-align: center;" type="checkbox"  id="allCheck"/></th><th class="table-title" style="text-align: center;">模块名称</th>
                 </tr>
             </thead>
          <tbody>
             <%for(list in pager.list!){%>
                <tr>
                 <td  style="text-align: center;">
                  <%if (list.enabled > 0){%>
		              <input type="checkbox" name="ids" value="${list.class_id}$${list.module_id}$${org_id}" checked="checked" >
		           <%}else{%>
		              <input type="checkbox" name="ids" value="${list.class_id}$${list.module_id}$${org_id}">
		           <%}%>
                 </td>
                 <td  style="text-align: center;">
		       		${list.name}
		         
                 </td>

               </tr>
             <%}%> 
          </tbody>
       </table>
       
       <%}%>
     </div>
   </div>
 </form>
 <div class="am-g">
 	<div class="am-u-sm-6 am-u-md-6 am-margin-left">
		<button type="button" name="theme_save" id="theme_save" class="am-btn am-btn-primary am-btn-xs">保存</button>		       
		<input id="id"  name="id" type="hidden" value="${id!}">
		<input id="class_name"  name="class_name" type="hidden"  value="${class_name!}"> 	       
	</div>	 
 </div>
 
 <script type="text/javascript">
function saveTheme(ids) {
    
    $.ajax({
        url : "${base}/website/save",
        data : {"ids":ids},
        async : true,
        success : function(data) {
        	 sendMessage({title: data.message, text: "", type: data.status,timer: 2000,   showConfirmButton: false});
             if(data.status=="success"){
        		history.back(-1);
        	}
        	
        }
        
    });
    
}
 

 
$(function(){
    $("#theme_save").on('click',function(event) {
    	
    	var ids=[];
    	$("input[name=ids]").each(function(index, el) {
    		if($(this).is(':checked')){
    			ids.push($(this).val()+'$1');
    		}else{
    			ids.push($(this).val()+'$0');
    		}
    		//ids.push($(this).val());	
    	});	
    	
    	saveTheme(ids.toString());
    });
    
    $('#org_id').on('change', function(){
    	console.log("change");
    	
    	window.location.replace("${base}/website/auth?id="+$("#id").val()+"&org_id="+$(this).val()+"&class_name="+$("#class_name").val());
    });
    
  });
  

</script>
<%}%>



